package com.enn.demo.application;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.enn.demo.application.assembler.PersonDTOAssembler;
import com.enn.demo.client.SysPersonQueryService;
import com.enn.demo.client.common.PageUtil;
import com.enn.demo.client.dto.PersonDTO;
import com.enn.demo.core.domain.model.person.PersonId;
import com.enn.demo.core.domain.repository.PersonRepository;
import com.enn.demo.application.assembler.PageAssembler;
import com.enn.demo.core.domain.util.mybatis.Query;
import com.enn.demo.dal.entity.SysPersonDO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author kll
 * @date 2021/5/14
 */
@Service
public class SysPersonQueryServiceImpl implements SysPersonQueryService {

    @Autowired
    private PersonRepository personRepository;

    @Override
    public PageUtil queryPage(Map<String, Object> params) {
        IPage<SysPersonDO> page = personRepository.queryPage(params);
        return PageAssembler.toPage(page);
    }

    @Override
    public PersonDTO find(String personId) {
        return PersonDTOAssembler.fromPerson(personRepository.find(new PersonId(personId)));
    }
}
